import React, { useEffect, useState } from 'react';
import { Form, Input, Select, Radio,Button } from 'antd';
import * as salary from '../../../../api/requestsalary.js'
import { useNavigate } from 'react-router-dom';
import '../Salary/AddGroup.scss'

function AddGroup(props: any) {
    var [addaccount1, setAddaccount1] = useState([])
    var [addaccount2, setAddaccount2] = useState([])
    var navigate = useNavigate()
    useEffect(() => { //核对算薪人员和薪资核算列表
        // salary.findathermon().then((res) => {
        //     console.log(res);
        //     setAddaccount2(res.data.data)
        // })
    }, [])
    const onFinish = async(values: any) => { //添加薪资核算表
        // console.log('Success:', values);
        var res=await salary.addgrop(values)
        // console.log(res);
        navigate('/index/moneys/salary/group')
    };
    return (
        <div className='addgroup'>
            <div className='addgroup-one'>
                <div className='addgroup-title-left'></div>
                <h4 className='addgroup-title'>薪资组设置</h4>
            </div>
            <div className='addgroup-two'>
                <Form
                    labelCol={{ span: 6 }}
                    wrapperCol={{ span: 14 }}
                    layout="horizontal"
                    onFinish={onFinish}
                    style={{ maxWidth: 600 }}
                >
                    <Form.Item label="薪资组名称" name='salary_group_name'>
                        <Input />
                    </Form.Item>
                    <Form.Item label="月计薪时长" name='monthly_working_hours'>
                        <Select
                            options={[
                                { value: "按月应出勤天数+法定节假日", label: "按月应出勤天数+法定节假日" },
                                { value: "按月应出勤天数", label: "按月应出勤天数" },
                                { value: "按月应出勤天数", label: "按月应出勤工时" },
                                { value: "按月应出勤天数", label: "按月应出勤工时++法定节假日" },
                                { value: "按月应出勤天数", label: "按月应出勤天数" },
                            ]}
                        />
                    </Form.Item>
                    <Form.Item label="计薪方式" name='salary_formula'>
                        <Radio.Group>
                            <Radio value="正算"> 正算 </Radio>
                            <Radio value="反算"> 反算 </Radio>
                        </Radio.Group>
                    </Form.Item>
                    <Form.Item label="适用人" name='ranges'>
                        <Select
                            options={[
                                { value: "敬光希", label: "敬光希" },
                                { value: "涂琼英", label: "涂琼英" }
                            ]}
                        />
                    </Form.Item>
                    <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                        <Button type="primary" htmlType="submit">保存</Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    );
}

export default AddGroup;